﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Mvc;

namespace QuDao.Api.Controllers
{
    /// <summary>
    /// 提现API
    /// </summary>
    public class CashApplyController : ApiControllerBase
    {
        /// <summary>
        /// 新增提现申请
        /// </summary>
        /// <param name="uid">用户ID</param>
        /// <param name="amount">提现金额</param>
        [HttpPost]
        public bool Add(long uid, decimal amount)
        {
            return CashApplyBO.Instance.Add(uid, amount) > 0;
        }

        /// <summary>
        /// 获取用户提现数据列表
        /// </summary>
        /// <param name="uid">用户ID</param>
        /// <param name="pageIndex">页索引，从1开始</param>
        /// <param name="pageSize">每页记录数，默认10</param>
        /// <returns></returns>
        [HttpGet]
        public List<CashApplyDto> GetList(long uid, int pageIndex = 1, int pageSize = 10)
        {
            var list = CashApplyBO.Instance.GetList(uid, pageIndex, pageSize);
            foreach (var item in list)
            {
                if (item.Status == 0) item.PaymentTime = item.CreateTime;
            }
            return list;
        }

    }
}
